package com.honour.controller.interfaced;



import java.util.ArrayList;



import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import com.honour.service.interfaced.MusicInManager;
import com.system.controller.base.BaseController;
import com.system.util.AppUtil;
import com.system.util.Const;
import com.system.util.HttpClientUtil;
import com.system.util.ListSortUtil;
import com.system.util.PageData;
import com.system.util.Tools;
import com.system.util.ToolsUtil;
import com.honour.service.interfaced.impl.AdvertisementInService;




/**
 @Function
 @Author 于泓磊
 @Date   2017年11月30日
*/

//获取歌曲详细
//songid 为歌曲id
//http://tingapi.ting.baidu.com/v1/restserver/ting?method=baidu.ting.song.play&songid=73984658

//获得歌曲歌词
//songid 歌曲id
//http://tingapi.ting.baidu.com/v1/restserver/ting?method=baidu.ting.song.lry&songid=877578

//获得所有模糊查询的歌曲列表
//query 歌曲模糊查询名称
//http://tingapi.ting.baidu.com/v1/restserver/ting?method=baidu.ting.search.catalogSug&query=海阔天空

//获得电台列表
//http://tingapi.ting.baidu.com/v1/restserver/ting?from=qianqian&version=2.1.0&method=baidu.ting.radio.getCategoryList&format=json

//获取某个电台下的歌曲列表
//http://tingapi.ting.baidu.com/v1/restserver/ting?from=qianqian&version=2.1.0&method=baidu.ting.radio.getChannelSong&format=json&pn=0&rn=10&channelname=public_tuijian_ktv

//获取排行榜列表  type为排行榜类型(1-新歌榜,2-热歌榜,11-摇滚榜,12-爵士,16-流行,21-欧美金曲榜,22-经典老歌榜,23-情歌对唱榜,24-影视金曲榜,25-网络歌曲榜),size为返回条目数量,offset为偏移数(页码)
//http://tingapi.ting.baidu.com/v1/restserver/ting?method=baidu.ting.billboard.billList&type=1&size=10&offset=0

//每日推荐歌曲(固定10首)
//http://tingapi.ting.baidu.com/v1/restserver/ting?method=baidu.ting.song.getRecommandSongList&song_id=877578&num=10

//新歌速递
//http://tingapi.ting.baidu.com/v1/restserver/ting?from=qianqian&version=2.1.0&method=baidu.ting.plaza.getNewSongs&format=json&limit=50

//新碟专辑
//http://tingapi.ting.baidu.com/v1/restserver/ting?from=qianqian&version=2.1.0&method=baidu.ting.plaza.getRecommendAlbum&format=json&offset=0&limit=50
	
//专辑信息
//http://tingapi.ting.baidu.com/v1/restserver/ting?from=qianqian&version=2.1.0&method=baidu.ting.album.getAlbumInfo&format=json&album_id=122314357

//歌手歌曲列表
//http://tingapi.ting.baidu.com/v1/restserver/ting?from=qianqian&version=2.1.0&method=baidu.ting.artist.getSongList&format=json?=2&tinguid=7994&offset=0&limits=50

//歌手模糊查询歌曲
//http://tingapi.ting.baidu.com/v1/restserver/ting?from=qianqian&version=2.1.0&method=baidu.ting.search.common&format=json&query=薛&page_no=1&page_size=10
	
//歌手简介
//http://tingapi.ting.baidu.com/v1/restserver/ting?from=qianqian&version=2.1.0&method=baidu.ting.artist.getinfo&format=json&tinguid=7994

//所有歌手列表
//http://tingapi.ting.baidu.com/v1/restserver/ting?from=qianqian&version=2.1.0&method=baidu.ting.artist.get72HotArtist&format=json?=1&offset=0&limit=50
@Controller
@RequestMapping(value="/appmusicin")
public class MusicInController extends BaseController{
	
	
	@Resource(name="musicinService")
	private MusicInManager musicinService;
	@Resource(name="advertisementInService")
	private AdvertisementInService advertisementInService;
	
	Gson gson = new Gson();
	

	/**
	 * 获得首页推荐音乐列表接口
	 * @Author 于泓磊
	 * @date   2017年11月30日
	 * @return
	 */
	@RequestMapping(value="/musicreclist")
	@ResponseBody
	public Object privilegeList(){
		logBefore(logger, "获得首页推荐音乐列表接口");
		Map<String,Object> map = new HashMap<String,Object>();
		PageData pd = new PageData();
		pd = this.getPageData();
		String result = "00";
		try{
			if(Tools.checkKey("MUSICLIST", pd.getString("FKEY"))){	//检验请求key值是否合法
				List<PageData> list = musicinService.getMusicList(pd);
				if (list.size()!=0) {
					map.put("pd", list);
				}
				result = (0== list.size()) ?  "02" :  "01";
			}else{
				result = "05";
			}
		}catch (Exception e){
			logger.error(e.toString(), e);
		}finally{
			map.put("result", result);
			logAfter(logger);
		}
		return AppUtil.returnObject(new PageData(), map);
	}
	
	/**
	 * 获得所有电台列表接口
	 * @Author 于泓磊
	 * @date   2017年12月7日
	 * @return
	 */
	@RequestMapping(value="/getcategorylist")
	@ResponseBody
	public Object getCategoryList(){
		logBefore(logger, "获得所有电台列表接口");
		PageData pd = new PageData();
		pd = this.getPageData();
		Map<String,Object> map = new HashMap<String,Object>();
		AppUtil.returnObject(new PageData(), map);
		String result="";
		try{
			if(Tools.checkKey("CATELIST", pd.getString("FKEY"))){	//检验请求key值是否合法
				//调用百度音乐api接口
				String strURL="http://tingapi.ting.baidu.com/v1/restserver/ting?from=qianqian&version=2.1.0&method=baidu.ting.radio.getCategoryList&format=json";
				result = HttpClientUtil.httpGetRequest(strURL);
				PageData p = gson.fromJson(result, PageData.class);
				//当请求次数到顶之后,再继续请求,直到请求有数据为止
				while (p.get("error_code").toString().equals("22001.0")) {
					strURL="http://tingapi.ting.baidu.com/v1/restserver/ting?from=qianqian&version=2.1.0&method=baidu.ting.radio.getCategoryList&format=json";
					result = HttpClientUtil.httpGetRequest(strURL);
					p = gson.fromJson(result, PageData.class);
				}
				String json = gson.toJson(p.get("result"));
				List<PageData> fromJson2 = ToolsUtil.fromJson(json, PageData.class);
				json = gson.toJson(fromJson2);
				List<PageData> list = new ArrayList<>();
				String readTxtFile = Tools.readTxtFile(Const.IMAGEPATH);
				String categoryimgs="musicimgs/categorylistimgs/";
				for (PageData pageDat : fromJson2) {
					String json2 = gson.toJson(pageDat.get("channellist"));
					List<PageData> list2 = ToolsUtil.fromJson(json2, PageData.class);
					for (PageData pageData : list2) {
						changeCategoryList(pageData, "漫步春天", "漫步春天", readTxtFile+categoryimgs+"music_image_41@2x.png",41);
						changeCategoryList(pageData, "秋日私语", "秋日私语", readTxtFile+categoryimgs+"music_image_43@2x.png",36);
						changeCategoryList(pageData, "温暖冬日", "温暖冬日", readTxtFile+categoryimgs+"music_image_44@2x.png",35);
						changeCategoryList(pageData, "热歌", "火爆热歌", readTxtFile+categoryimgs+"music_image_51@2x.png",7);
						changeCategoryList(pageData, "KTV金曲", "KTV必点", readTxtFile+categoryimgs+"music_image_50@2x.png",38);
						changeCategoryList(pageData, "Billboard", "Billboard", readTxtFile+categoryimgs+"music_image_49@2x.png",6);
						changeCategoryList(pageData, "成名曲", "一人一首成名曲", readTxtFile+categoryimgs+"music_image_48@2x.png",8);
						changeCategoryList(pageData, "开车", "开车不喝酒喝酒不开车", readTxtFile+categoryimgs+"music_image_45@2x.png",34);
						changeCategoryList(pageData, "网络歌曲", "网络神曲", readTxtFile+categoryimgs+"music_image_47@2x.png",37);
						changeCategoryList(pageData, "影视", "影视原声", readTxtFile+categoryimgs+"music_image_46@2x.png",9);
						changeCategoryList(pageData, "随便听听", "随心所欲", readTxtFile+categoryimgs+"music_image_47@2x.png",33);
						changeCategoryList(pageData, "经典老歌", "老歌怀旧", readTxtFile+categoryimgs+"music_image_48@2x.png",32);
						changeCategoryList(pageData, "70后", "忘情水海洋", readTxtFile+categoryimgs+"music_image_49@2x.png",31);
						changeCategoryList(pageData, "80后", "不再犹豫不觉", readTxtFile+categoryimgs+"music_image_50@2x.png",30);
						changeCategoryList(pageData, "90后", "非你莫属于我", readTxtFile+categoryimgs+"music_image_51@2x.png",23);
						changeCategoryList(pageData, "火爆新歌", "冲榜新歌", readTxtFile+categoryimgs+"music_image_52@2x.png",11);
						changeCategoryList(pageData, "儿歌", "童声无限", readTxtFile+categoryimgs+"music_image_42@2x.png",39);
						changeCategoryList(pageData, "旅行", "漫步去旅行", readTxtFile+categoryimgs+"music_image_43@2x.png",12);
						changeCategoryList(pageData, "夜店", "High翻全场", readTxtFile+categoryimgs+"music_image_46@2x.png",5);
						changeCategoryList(pageData, "流行", "当今最流行", readTxtFile+categoryimgs+"music_image_45@2x.png",4);
						changeCategoryList(pageData, "摇滚", "摇滚不死", readTxtFile+categoryimgs+"music_image_44@2x.png",3);
						changeCategoryList(pageData, "民谣", "民谣唱法", readTxtFile+categoryimgs+"music_image_47@2x.png",13);
						changeCategoryList(pageData, "轻音乐", "舒缓轻音乐", readTxtFile+categoryimgs+"music_image_44@2x.png",14);
						changeCategoryList(pageData, "中国风", "盛兴中国风", readTxtFile+categoryimgs+"music_image_45@2x.png",29);
						changeCategoryList(pageData, "小清新", "开拓新视野", readTxtFile+categoryimgs+"music_image_46@2x.png",15);
						changeCategoryList(pageData, "DJ舞曲", "百大DJ经典舞曲", readTxtFile+categoryimgs+"music_image_43@2x.png",2);
						changeCategoryList(pageData, "电影", "电影插曲", readTxtFile+categoryimgs+"music_image_42@2x.png",28);
						changeCategoryList(pageData, "轻松假日", "给自己放个假", readTxtFile+categoryimgs+"music_image_48@2x.png",27);
						changeCategoryList(pageData, "欢快旋律", "左脚踩右脚能上天", readTxtFile+categoryimgs+"music_image_49@2x.png",16);
						changeCategoryList(pageData, "甜蜜感受", "你是我最想留住的幸运", readTxtFile+categoryimgs+"music_image_50@2x.png",17);
						changeCategoryList(pageData, "寂寞", "孤独寂寞冷", readTxtFile+categoryimgs+"music_image_51@2x.png",18);
						changeCategoryList(pageData, "单身情歌", "单身狗也挺好", readTxtFile+categoryimgs+"music_image_52@2x.png",19);
						changeCategoryList(pageData, "舒缓节奏", "舒缓压力放轻松", readTxtFile+categoryimgs+"music_image_41@2x.png",20);
						changeCategoryList(pageData, "慵懒午后", "睡个午觉吧", readTxtFile+categoryimgs+"music_image_41@2x.png",26);
						changeCategoryList(pageData, "伤感", "伤心的人别听慢歌", readTxtFile+categoryimgs+"music_image_43@2x.png",25);
						changeCategoryList(pageData, "华语", "巅峰华语", readTxtFile+categoryimgs+"music_image_44@2x.png",21);
						changeCategoryList(pageData, "欧美", "SuperCool", readTxtFile+categoryimgs+"music_image_45@2x.png",1);
						changeCategoryList(pageData, "日语", "脍炙日语", readTxtFile+categoryimgs+"music_image_46@2x.png",24);
						changeCategoryList(pageData, "韩语", "潮流韩语", readTxtFile+categoryimgs+"music_image_47@2x.png",22);
						changeCategoryList(pageData, "粤语", "经典粤语", readTxtFile+categoryimgs+"music_image_48@2x.png",10);
					list.add(pageData);
					}
					//将集合重新排序
					List<PageData> finallist=new ArrayList<>();
					for (PageData pa : list) {
						if (pa.get("precountout")!=null) {
							finallist.add(pa);
						}
					}
					list.clear();
					for (PageData pa : finallist) {
						if (pa.get("cate_sname").equals(pd.get("cate_sname"))) {
							list.add(pa);
						}
						if ("-1".equals(pd.get("cate_sname"))) {
							list=finallist;
						}
					}
					ListSortUtil.sort(list);
					pageDat.put("channellist", list);
					pageDat.put("title", pageDat.get("title"));
					pageDat.put("cid", pageDat.get("cid"));
					p.put("result", pageDat);
				}
				result= gson.toJson(p);
			/*	result=UnicodeUtil.decode(result);*/
				p=gson.fromJson(result, PageData.class);
				map.put("result", "01");
				map.put("pd",p);
				
			}else{
				result = "05";
				map.put("result", result);
			}
		}catch (Exception e){
			logger.error(e.toString(), e);
		}finally{
			logAfter(logger);
		}
		return AppUtil.returnObject(new PageData(), map);
	}
	
	
	
	
	/**
	 * 获取某个电台下的歌曲列表接口
	 * @Author 于泓磊
	 * @date   2017年12月7日
	 * @return
    */
	@RequestMapping(value="/getchannelsong")
	@ResponseBody
	public Object getChannelSong(){
		logBefore(logger, "获取某个电台下的歌曲列表接口");
		PageData pd = new PageData();
		pd = this.getPageData();
		Map<String,Object> map = new HashMap<String,Object>();
		AppUtil.returnObject(new PageData(), map);
		String result="";
		try{
			if(Tools.checkKey("CANNELSONG", pd.getString("FKEY"))){	//检验请求key值是否合法
				if(AppUtil.checkParam("checkchannel", pd)){	//检查参数
				//调用百度音乐api接口
				String strURL="http://tingapi.ting.baidu.com/v1/restserver/ting?from=qianqian&version=2.1.0&method=baidu.ting.radio.getChannelSong&format=json&pn=0&rn=10&channelname="+pd.getString("ch_name");
				result = HttpClientUtil.httpGetRequest(strURL);
				PageData p = gson.fromJson(result, PageData.class);
				List<PageData> list=new ArrayList<>();
				while (p.get("error_code").toString().equals("22001.0")) {
					strURL="http://tingapi.ting.baidu.com/v1/restserver/ting?from=qianqian&version=2.1.0&method=baidu.ting.radio.getChannelSong&format=json&pn=0&rn=10&channelname="+pd.getString("ch_name");
					result = HttpClientUtil.httpGetRequest(strURL);
					p = gson.fromJson(result, PageData.class);
				}
				//将接口返回的空串进行过滤
				String json = gson.toJson(p.get("result"));
				PageData presult = gson.fromJson(json, PageData.class);
				String json2 = gson.toJson(presult.get("songlist"));
				List<PageData> fromjson = ToolsUtil.fromJson(json2, PageData.class);
				for (PageData pageData : fromjson) {
					if (pageData.containsKey("songid")&&pageData.containsKey("artist")) {
						list.add(pageData);
					}
				}
				presult.put("songlist", list);
				p.put("result", presult);
				result= gson.toJson(p);
			/*	result=UnicodeUtil.decode(result);*/
				p=gson.fromJson(result, PageData.class);
				map.put("result", "01");
				map.put("pd",p);
				}else {
					result = "03";
					map.put("result", result);
				}
			}else{
				result = "05";
				map.put("result", result);
			}
		}catch (Exception e){
			logger.error(e.toString(), e);
		}finally{
			logAfter(logger);
		}
		return AppUtil.returnObject(new PageData(), map);
	}
	
	
	/**
	 * 获取歌曲详细接口
	 * @Author 于泓磊
	 * @date   2017年12月7日
	 * @return
	 */
	@RequestMapping(value="/getsongplay")
	@ResponseBody
	public Object getSongPlay(){
		logBefore(logger, "获取歌曲详细接口");
		PageData pd = new PageData();
		pd = this.getPageData();
		Map<String,Object> map = new HashMap<String,Object>();
		AppUtil.returnObject(new PageData(), map);
		String result="";
		String resultlrc="";
		try{
			if(Tools.checkKey("SONGPLAY", pd.getString("FKEY"))){	//检验请求key值是否合法
				if(AppUtil.checkParam("songplay", pd)){	//检查参数
				//调用百度音乐api接口
				String strURL="http://tingapi.ting.baidu.com/v1/restserver/ting?method=baidu.ting.song.play&songid="+pd.getString("songid");
				String strURLlrc="http://tingapi.ting.baidu.com/v1/restserver/ting?method=baidu.ting.song.lry&songid="+pd.getString("songid");
				resultlrc = HttpClientUtil.httpGetRequest(strURLlrc);
				result = HttpClientUtil.httpGetRequest(strURL);
				PageData p = gson.fromJson(result,new TypeToken<PageData>() {}.getType()); 
			/*	PageData p = gson.fromJson(result, PageData.class);*/
				PageData plrc = gson.fromJson(resultlrc,new TypeToken<PageData>() {}.getType()); 
				/*PageData plrc = gson.fromJson(resultlrc, PageData.class);*/
				String json = gson.toJson(p.get("songinfo"));
				PageData pinfo = gson.fromJson(json, PageData.class);
				pinfo.put("lrclink", plrc);
				p.put("songinfo", pinfo);
				result= gson.toJson(p);
				p=gson.fromJson(result, PageData.class);
				map.put("result", "01");
				map.put("pd",p);
				}else {
					result = "03";
					map.put("result", result);
				}
			}else{
				result = "05";
				map.put("result", result);
			}
		}catch (Exception e){
			logger.error(e.toString(), e);
		}finally{
			logAfter(logger);
		}
		return AppUtil.returnObject(new PageData(), map);
	}
	
	/**
	 * 获得所有模糊查询的歌曲列表接口
	 * @Author 于泓磊
	 * @date   2017年12月7日
	 * @return
	 */
	@RequestMapping(value="/getsearchsong")
	@ResponseBody
	public Object getSearchSong(){
		logBefore(logger, "获得所有模糊查询的歌曲列表接口");
		PageData pd = new PageData();
		pd = this.getPageData();
		Map<String,Object> map = new HashMap<String,Object>();
		AppUtil.returnObject(new PageData(), map);
		String result="";
		try{
			if(Tools.checkKey("SEARCHSONG", pd.getString("FKEY"))){	//检验请求key值是否合法
				if(AppUtil.checkParam("searchsong", pd)){	//检查参数
				//调用百度音乐api接口
				String strURL="http://tingapi.ting.baidu.com/v1/restserver/ting?method=baidu.ting.search.catalogSug&query="+pd.getString("query");
				result = HttpClientUtil.httpGetRequest(strURL);
				PageData p = gson.fromJson(result, PageData.class);
				result= gson.toJson(p);
				/*result=UnicodeUtil.decode(result);*/
				p=gson.fromJson(result, PageData.class);
				map.put("result", "01");
				map.put("pd",p);
				}else {
					result = "03";
					map.put("result", result);
				}
			}else{
				result = "05";
				map.put("result", result);
			}
		}catch (Exception e){
			logger.error(e.toString(), e);
		}finally{
			logAfter(logger);
		}
		return AppUtil.returnObject(new PageData(), map);
	}
	
	/**
	 * 获得排行榜列表接口
	 * @Author 于泓磊
	 * @date   2017年12月7日
	 * @return
	 */
	@RequestMapping(value="/getbilllist")
	@ResponseBody
	public Object getBillList(){
		logBefore(logger, "获得排行榜列表接口");
		PageData pd = new PageData();
		pd = this.getPageData();
		Map<String,Object> map = new HashMap<String,Object>();
		AppUtil.returnObject(new PageData(), map);
		String result="";
		try{
			if(Tools.checkKey("BILLLIST", pd.getString("FKEY"))){	//检验请求key值是否合法
				if(AppUtil.checkParam("billlist", pd)){	//检查参数
				//调用百度音乐api接口
				String strURL="http://tingapi.ting.baidu.com/v1/restserver/ting?method=baidu.ting.billboard.billList&type="+pd.getString("type")+"&size=10&offset="+pd.getString("offset");
				result = HttpClientUtil.httpGetRequest(strURL);
				//将返回的Http请求数据转变成PageData实体对象
				PageData p = gson.fromJson(result, PageData.class);
				
				//将排行榜图片改成自定义图片
				String json = gson.toJson(p.get("billboard"));
				PageData pda = gson.fromJson(json, PageData.class);
				switch (Integer.parseInt((String) pd.get("type"))) {
				case 21:
					pda.put("pic_s640", "http://image.rongyaohk.com/musicimgs/billlistimgs/music_image_34@2x.png");
					break;
				case 1:
					pda.put("pic_s640", "http://image.rongyaohk.com/musicimgs/billlistimgs/music_image_35@2x.png");
					break;
				case 22:
					pda.put("pic_s640", "http://image.rongyaohk.com/musicimgs/billlistimgs/music_image_40@2x.png");
					break;
				case 2:
					pda.put("pic_s640", "http://image.rongyaohk.com/musicimgs/billlistimgs/music_image_37@2x.png");
					break;
				case 11:
					pda.put("pic_s640", "http://image.rongyaohk.com/musicimgs/billlistimgs/music_image_36@2x.png");
					break;
				case 24:
					pda.put("pic_s640", "http://image.rongyaohk.com/musicimgs/billlistimgs/music_image_38@2x.png");
					break;
				case 12:
					pda.put("pic_s640", "http://image.rongyaohk.com/musicimgs/billlistimgs/music_image_39@2x.png");
					break;
				default:
					break;
				}
				//将修改完的字段传入p对象中
				p.put("billboard", pda);
				//将整个PageData对象转换成Json串
				result= gson.toJson(p, PageData.class);
				/*//将Json串中的Unicode码转换为汉字
				result=UnicodeUtil.decode(result);*/
				//将Json串转为PageData对象并存在map集合中
				p=gson.fromJson(result, PageData.class);
				map.put("result", "01");
				map.put("pd",p);
				}else {
					result = "03";
					map.put("result", result);
				}
			}else{
				result = "05";
				map.put("result", result);
			}
		}catch (Exception e){
			logger.error(e.toString(), e);
		}finally{
			logAfter(logger);
		}
		return AppUtil.returnObject(new PageData(), map);
	}
	

	/**
	 * 获得歌曲歌词接口
	 * @Author 于泓磊
	 * @date   2017年12月7日
	 * @return
	 */
	@RequestMapping(value="/getlry")
	@ResponseBody
	public Object getLry(){
		logBefore(logger, "获得歌曲歌词接口");
		PageData pd = new PageData();
		pd = this.getPageData();
		Map<String,Object> map = new HashMap<String,Object>();
		AppUtil.returnObject(new PageData(), map);
		String result="";
		try{
			if(Tools.checkKey("LRY", pd.getString("FKEY"))){	//检验请求key值是否合法
				if(AppUtil.checkParam("lry", pd)){	//检查参数
				//调用百度音乐api接口
				String strURL="http://tingapi.ting.baidu.com/v1/restserver/ting?method=baidu.ting.song.lry&songid="+pd.getString("songid");
				result = HttpClientUtil.httpGetRequest(strURL);
				PageData p = gson.fromJson(result, PageData.class);
				result= gson.toJson(p);
				/*result=UnicodeUtil.decode(result);*/
				p=gson.fromJson(result, PageData.class);
				map.put("result", "01");
				map.put("pd",p);
				}else {
					result = "03";
					map.put("result", result);
				}
			}else{
				result = "05";
				map.put("result", result);
			}
		}catch (Exception e){
			logger.error(e.toString(), e);
		}finally{
			logAfter(logger);
		}
		return AppUtil.returnObject(new PageData(), map);
	}
	
	
	/**
	 * 每日推荐歌曲(固定10首)
	 * @Author 于泓磊
	 * @date   2017年12月7日
	 * @return
	 */
	@RequestMapping(value="/getrecommandsonglist")
	@ResponseBody
	public Object getRecommandSongList(){
		logBefore(logger, "每日推荐歌曲(固定10首)");
		PageData pd = new PageData();
		pd = this.getPageData();
		Map<String,Object> map = new HashMap<String,Object>();
		AppUtil.returnObject(new PageData(), map);
		String result="";
		try{
			if(Tools.checkKey("SONGLIST", pd.getString("FKEY"))){	//检验请求key值是否合法
				//调用百度音乐api接口
				String strURL="http://tingapi.ting.baidu.com/v1/restserver/ting?method=baidu.ting.song.getRecommandSongList&num=10&song_id=877578";
				result = HttpClientUtil.httpGetRequest(strURL);
				/*PageData p = gson.fromJson(result, PageData.class);*/
				/*result= gson.toJson(p);*/
				/*result=UnicodeUtil.decode(result);*/
				PageData p=gson.fromJson(result, PageData.class);
				map.put("result", "01");
				map.put("pd",p);
			}else{
				result = "05";
				map.put("result", result);
			}
		}catch (Exception e){
			logger.error(e.toString(), e);
		}finally{
			logAfter(logger);
		}
		return AppUtil.returnObject(new PageData(), map);
	}
	
	
	/**
	 * 通过歌手获取其所有歌曲列表接口
	 * @Author 于泓磊
	 * @date   2017年12月8日
	 * @return
	 */
	@RequestMapping(value="/getsonglist")
	@ResponseBody
	public Object getSongList(){
		logBefore(logger, "通过歌手获取其歌曲列表接口");
		PageData pd = new PageData();
		pd = this.getPageData();
		Map<String,Object> map = new HashMap<String,Object>();
		AppUtil.returnObject(new PageData(), map);
		String result="";
		try{
			if(Tools.checkKey("SONGLIST", pd.getString("FKEY"))){	//检验请求key值是否合法
				if(AppUtil.checkParam("songlist", pd)){	//检查参数
				//调用百度音乐api接口
				String strURL="http://tingapi.ting.baidu.com/v1/restserver/ting?from=qianqian&version=2.1.0&method=baidu.ting.artist.getSongList&format=json?=2&tinguid="+pd.getString("tinguid")+"&offset="+pd.getString("offset")+"&limits=10";
				result = HttpClientUtil.httpGetRequest(strURL);
				PageData p = gson.fromJson(result,new TypeToken<PageData>() {}.getType()); 
				/* PageData p = gson.fromJson(result, PageData.class);*/
				result= gson.toJson(p);
				/*result=UnicodeUtil.decode(result);*/
				p=gson.fromJson(result, PageData.class);
				map.put("result", "01");
				map.put("pd",p);
				}else {
					result = "03";
					map.put("result", result);
				}
			}else{
				result = "05";
				map.put("result", result);
			}
		}catch (Exception e){
			logger.error(e.toString(), e);
		}finally{
			logAfter(logger);
		}
		return AppUtil.returnObject(new PageData(), map);
	}

	
	/**
	 * 新歌速递接口
	 * @Author 于泓磊
	 * @date   2017年12月8日
	 * @return
	 */
	@RequestMapping(value="/getnewsongs")
	@ResponseBody
	public Object getNewSongs(){
		logBefore(logger, "新歌速递接口");
		PageData pd = new PageData();
		pd = this.getPageData();
		Map<String,Object> map = new HashMap<String,Object>();
		AppUtil.returnObject(new PageData(), map);
		String result="";
		try{
			if(Tools.checkKey("NEWSONGS", pd.getString("FKEY"))){	//检验请求key值是否合法
				//调用百度音乐api接口
				String strURL="http://tingapi.ting.baidu.com/v1/restserver/ting?from=qianqian&version=2.1.0&method=baidu.ting.plaza.getNewSongs&format=json&limit=10";
				result = HttpClientUtil.httpGetRequest(strURL);
				PageData p = gson.fromJson(result, PageData.class);
				result= gson.toJson(p);
				/*result=UnicodeUtil.decode(result);*/
				p=gson.fromJson(result, PageData.class);
				map.put("result", "01");
				map.put("pd",p);
			}else{
				result = "05";
				map.put("result", result);
			}
		}catch (Exception e){
			logger.error(e.toString(), e);
		}finally{
			logAfter(logger);
		}
		return AppUtil.returnObject(new PageData(), map);
	}
	
	/**
	 * 新碟专辑接口
	 * @Author 于泓磊
	 * @date   2017年12月8日
	 * @return
	 */
	@RequestMapping(value="/getrecommendalbum")
	@ResponseBody
	public Object getRecommendAlbum(){
		logBefore(logger, "新碟专辑接口");
		PageData pd = new PageData();
		pd = this.getPageData();
		Map<String,Object> map = new HashMap<String,Object>();
		AppUtil.returnObject(new PageData(), map);
		String result="";
		try{
			if(Tools.checkKey("ALBUM", pd.getString("FKEY"))){	//检验请求key值是否合法
				if(AppUtil.checkParam("album", pd)){	//检查参数
				//调用百度音乐api接口
				String strURL="http://tingapi.ting.baidu.com/v1/restserver/ting?from=qianqian&version=2.1.0&method=baidu.ting.plaza.getRecommendAlbum&format=json&offset="+pd.getString("offset")+"&limit=10";
				result = HttpClientUtil.httpGetRequest(strURL);
				PageData p = gson.fromJson(result, PageData.class);
				result= gson.toJson(p);
				/*result=UnicodeUtil.decode(result);*/
				p=gson.fromJson(result, PageData.class);
				map.put("result", "01");
				map.put("pd",p);
				}else {
					result = "03";
					map.put("result", result);
				}
			}else{
				result = "05";
				map.put("result", result);
			}
		}catch (Exception e){
			logger.error(e.toString(), e);
		}finally{
			logAfter(logger);
		}
		return AppUtil.returnObject(new PageData(), map);
	}
	
	/**
	 * 专辑详细信息接口
	 * @Author 于泓磊
	 * @date   2017年12月8日
	 * @return
	 */
	@RequestMapping(value="/getalbuminfo")
	@ResponseBody
	public Object getAlbumInfo(){
		logBefore(logger, "专辑详细信息接口");
		PageData pd = new PageData();
		pd = this.getPageData();
		Map<String,Object> map = new HashMap<String,Object>();
		AppUtil.returnObject(new PageData(), map);
		String result="";
		try{
			if(Tools.checkKey("ALBUMINFO", pd.getString("FKEY"))){	//检验请求key值是否合法
				if(AppUtil.checkParam("albuminfo", pd)){	//检查参数
				//调用百度音乐api接口
				String strURL="http://tingapi.ting.baidu.com/v1/restserver/ting?from=qianqian&version=2.1.0&method=baidu.ting.album.getAlbumInfo&format=json&album_id="+pd.getString("album_id");
				result = HttpClientUtil.httpGetRequest(strURL);
				PageData p = gson.fromJson(result, PageData.class);
				result= gson.toJson(p);
				/*result=UnicodeUtil.decode(result);*/
				p=gson.fromJson(result, PageData.class);
				map.put("result", "01");
				map.put("pd",p);
				}else {
					result = "03";
					map.put("result", result);
				}
			}else{
				result = "05";
				map.put("result", result);
			}
		}catch (Exception e){
			logger.error(e.toString(), e);
		}finally{
			logAfter(logger);
		}
		return AppUtil.returnObject(new PageData(), map);
	}
	
	/**
	 * 歌手模糊查询歌曲接口
	 * @Author 于泓磊
	 * @date   2017年12月8日
	 * @return
	 */
	@RequestMapping(value="/getsearchsongs")
	@ResponseBody
	public Object getSearchSongs(){
		logBefore(logger, "歌手模糊查询歌曲接口");
		PageData pd = new PageData();
		pd = this.getPageData();
		Map<String,Object> map = new HashMap<String,Object>();
		AppUtil.returnObject(new PageData(), map);
		String result="";
		try{
			if(Tools.checkKey("SEARCHSONGS", pd.getString("FKEY"))){	//检验请求key值是否合法
				if(AppUtil.checkParam("searchsongs", pd)){	//检查参数
				//调用百度音乐api接口
				String strURL="http://tingapi.ting.baidu.com/v1/restserver/ting?from=qianqian&version=2.1.0&method=baidu.ting.search.common&format=json&query="+pd.getString("query")+"&page_no="+pd.getString("offset")+"&page_size=10";
				result = HttpClientUtil.httpGetRequest(strURL);
				PageData p = gson.fromJson(result, PageData.class);
				result= gson.toJson(p);
				p=gson.fromJson(result, PageData.class);
				map.put("result", "01");
				map.put("pd",p);
				}else {
					result = "03";
					map.put("result", result);
				}
			}else{
				result = "05";
				map.put("result", result);
			}
		}catch (Exception e){
			logger.error(e.toString(), e);
		}finally{
			logAfter(logger);
		}
		return AppUtil.returnObject(new PageData(), map);
	}
	
	/**
	 * 歌手简介接口
	 * @Author 于泓磊
	 * @date   2017年12月8日
	 * @return
	 */
	@RequestMapping(value="/getartistinfo")
	@ResponseBody
	public Object getArtistInfo(){
		logBefore(logger, "歌手简介接口");
		PageData pd = new PageData();
		pd = this.getPageData();
		Map<String,Object> map = new HashMap<String,Object>();
		AppUtil.returnObject(new PageData(), map);
		String result="";
		
		try{
			if(Tools.checkKey("ARTISTINFO", pd.getString("FKEY"))){	//检验请求key值是否合法
				if(AppUtil.checkParam("artistinfo", pd)){	//检查参数
				//调用百度音乐api接口
				String strURL="http://tingapi.ting.baidu.com/v1/restserver/ting?from=qianqian&version=2.1.0&method=baidu.ting.artist.getinfo&format=json&tinguid="+pd.getString("tinguid");
				result = HttpClientUtil.httpGetRequest(strURL);
				PageData p = gson.fromJson(result, PageData.class);
				result= gson.toJson(p);
				p=gson.fromJson(result, PageData.class);
				map.put("result", "01");
				map.put("pd",p);
				}else {
					result = "03";
					map.put("result", result);
				}
			}else{
				result = "05";
				map.put("result", result);
			}
		}catch (Exception e){
			logger.error(e.toString(), e);
		}finally{
			logAfter(logger);
		}
		
		return AppUtil.returnObject(new PageData(), map);
	}
	
	/**
	 * 所有歌手列表接口
	 * @Author 于泓磊
	 * @date   2017年12月8日
	 * @return
	 */
	@RequestMapping(value="/gethotartist")
	@ResponseBody
	public Object getHotArtist(){
		logBefore(logger, "所有歌手列表接口");
		PageData pd = new PageData();
		pd = this.getPageData();
		Map<String,Object> map = new HashMap<String,Object>();
		AppUtil.returnObject(new PageData(), map);
		String result="";
		try{
			if(Tools.checkKey("HOTARTIST", pd.getString("FKEY"))){	//检验请求key值是否合法
				if(AppUtil.checkParam("album", pd)){	//检查参数
				//调用百度音乐api接口
				String strURL="http://tingapi.ting.baidu.com/v1/restserver/ting?from=qianqian&version=2.1.0&method=baidu.ting.artist.get72HotArtist&format=json?=1&offset="+pd.getString("offset")+"&limit=100";
				result = HttpClientUtil.httpGetRequest(strURL);
				PageData p = gson.fromJson(result, PageData.class);
				//获得歌手列表
				String json = gson.toJson(p.get("artist"));
				List<PageData> list=new ArrayList<>();
				if (pd.get("gender")!=null&&pd.get("area")!=null) {
					List<PageData> fromJson = ToolsUtil.fromJson(json, PageData.class);
					for (PageData pageData : fromJson) {
						if (pageData.get("gender").toString().equals(pd.get("gender"))&&pageData.get("area").toString().equals(pd.get("area"))) {
							list.add(pageData);
						}
					}
					p.put("artist", list);
				}else if (pd.get("gender")!=null&&pd.get("area")==null) {
					List<PageData> fromJson = ToolsUtil.fromJson(json, PageData.class);
					for (PageData pageData : fromJson) {
						if (pageData.get("gender").toString().equals(pd.get("gender"))) {
							list.add(pageData);
						}
					}
					p.put("artist", list);
				}else if (pd.get("area")!=null&&pd.get("gender")==null) {
						List<PageData> fromJson = ToolsUtil.fromJson(json, PageData.class);
						for (PageData pageData : fromJson) {
							if (pageData.get("area").toString().equals(pd.get("area"))) {
								list.add(pageData);
							}
						}
						p.put("artist", list);
					}
				result= gson.toJson(p);
				/*result=UnicodeUtil.decode(result);*/
				p=gson.fromJson(result, PageData.class);
				json= gson.toJson(p.get("artist"));
				List<PageData> fromJson = ToolsUtil.fromJson(json, PageData.class);
				if (fromJson.size()==0) {
					map.put("result", "02");
					p=null;
				}else{
					map.put("result", "01");
				}
				map.put("pd",p);
				if (pd.get("offset").equals("100")) {
					p.put("artist", "");
				}
				}else {
					result = "03";
					map.put("result", result);
				}
			}else{
				result = "05";
				map.put("result", result);
			}
		}catch (Exception e){
			logger.error(e.toString(), e);
		}finally{
			logAfter(logger);
		}
		
		return AppUtil.returnObject(new PageData(), map);
	}
	
	
	/**
	 * 获得所有排行榜列表接口(每个排行榜显示3首)
	 * @Author 于泓磊
	 * @date   2017年12月7日
	 * @return
	 */
	@RequestMapping(value="/getbilllistall")
	@ResponseBody
	public Object getBillListForThree(){
		logBefore(logger, "获得所有排行榜列表接口(每个排行榜显示3首)接口");
		PageData pd = new PageData();
		pd = this.getPageData();
		Map<String,Object> map = new HashMap<String,Object>();
		AppUtil.returnObject(new PageData(), map);
		String result="";
		List<PageData> list = new ArrayList<>();
		try{
			if(Tools.checkKey("BILLLIST", pd.getString("FKEY"))){	//检验请求key值是否合法
				/*if(AppUtil.checkParam("billlist", pd)){	//检查参数
*/				String str=	(String) pd.get("type");
				//调用百度音乐api接口
                String[] split = str.split(",");
                String strURL="";
                for (String s : split) {
                	strURL="http://tingapi.ting.baidu.com/v1/restserver/ting?method=baidu.ting.billboard.billList&type="+s+"&size=10&offset="+pd.getString("offset");
                	result = HttpClientUtil.httpGetRequest(strURL);
    				//将返回的Http请求数据转变成PageData实体对象
    				PageData p = gson.fromJson(result, PageData.class);
    				//将排行榜数据提取前三名显示
    				String json2 = gson.toJson(p.get("song_list"));
    				List<PageData> fromJson = ToolsUtil.fromJson(json2, PageData.class);
    				List<PageData> pdlist=new ArrayList<>(); 
    				for (int i = 0; i < 3; i++) {
    					pdlist.add(fromJson.get(i));
    				}
    				//将排行榜图片改成自定义图片
    				String json = gson.toJson(p.get("billboard"));
    				PageData pda = gson.fromJson(json, PageData.class);
    				String path = Tools.readTxtFileAll(Const.IMAGEPATH, "UTF-8");
    				switch (Integer.parseInt(s)) {
    				case 21:
    					pda.put("pic_s640", path+"musicimgs/billlistimgs/music_image_34@2x.png");
    					break;
    				case 1:
    					pda.put("pic_s640", path+"musicimgs/billlistimgs/music_image_35@2x.png");
    					break;
    				case 22:
    					pda.put("pic_s640", path+"musicimgs/billlistimgs/music_image_40@2x.png");
    					break;
    				case 2:
    					pda.put("pic_s640", path+"musicimgs/billlistimgs/music_image_37@2x.png");
    					break;
    				case 11:
    					pda.put("pic_s640", path+"musicimgs/billlistimgs/music_image_36@2x.png");
    					break;
    				case 24:
    					pda.put("pic_s640", path+"musicimgs/billlistimgs/music_image_38@2x.png");
    					break;
    				case 12:
    					pda.put("pic_s640", path+"musicimgs/billlistimgs/music_image_39@2x.png");
    					break;
    				default:
    					break;
    				}
    				//将修改完的字段传入p对象中
    				p.put("song_list", pdlist);
    				p.put("billboard", pda);
    				//将整个PageData对象转换成Json串
    				result= gson.toJson(p, PageData.class);
    				//将Json串中的Unicode码转换为汉字
    			/*	result=UnicodeUtil.decode(result);*/
    				//将Json串转为PageData对象并存在map集合中
    				p=gson.fromJson(result, PageData.class);
    				list.add(p);
                }
				/*}else {
					result = "03";
					map.put("result", result);
				}*/
                map.put("result", "01");
                map.put("pd", list);
			}else{
				result = "05";
				map.put("result", result);
			}
		}catch (Exception e){
			logger.error(e.toString(), e);
		}finally{
			logAfter(logger);
		}
		return AppUtil.returnObject(new PageData(), map);
	}
	
	/*
	 * 电台更换图片电台名排序工具类
	 * @Author 于泓磊
	 * @date   2017年12月15日
	 * @param pageData
	 * @param title 需要更改的原电台名
	 * @param name  需要更改的新电台名
	 * @param thumb 需要更改的新图片地址
	 * @param precountout  排序
	 */
	public void changeCategoryList(PageData pageData,String title,String name,String thumb,Integer precountout){
		if (pageData.get("name").equals(title)) {
			pageData.put("name", name);
			pageData.put("thumb", thumb);
			pageData.put("precountout", precountout);
		}
		
	}
	
	/**
	 * 音乐中心-首页：歌手推荐和广告
	 * @Author zhaozhenhua
	 * @date   2018年1月18日
	 * @return
	 */
	@RequestMapping(value="/getsongrecommend")
	@ResponseBody
	public Object getSongRecommend(){
		logBefore(logger, "音乐中心-首页：歌手推荐和广告");
		PageData pd = new PageData();
		pd = this.getPageData();
		Map<String,Object> map = new HashMap<String,Object>();
		AppUtil.returnObject(new PageData(), map);
		List<PageData> singerList = new ArrayList<>();
		String path = Tools.readTxtFileAll(Const.IMAGEPATH, "UTF-8");
		try{
			if(Tools.checkKey("SONGRECOMMEND", pd.getString("FKEY"))){	//检验请求key值是否合法
					//添加广告
					pd.put("RELATED_ID", "8");
					List<PageData> ads = advertisementInService.getAdByPosition(pd);
	                //荣耀音乐-歌手推荐	
					String singer=	"7996,7994,7997,7998";
					String[] singers = singer.split(",");
					for (String s : singers) {
						PageData song=new PageData();
						song.put("singer_id", s);
						switch (Integer.parseInt(s)) {
    					case 7994:
    						song.put("singer_pic", path+"musicimgs/singers/music_banner_2@2x.png");
    						break;
    					case 7996:
    						song.put("singer_pic", path+"musicimgs/singers/music_banner_3@2x.png");
    						break;
    					case 7997:
    						song.put("singer_pic", path+"musicimgs/singers/music_banner_4@2x.png");
    						break;
    					case 7998:
    						song.put("singer_pic", path+"musicimgs/singers/music_banner_5@2x.png");
    						break;
    					default:
    						break;
    					}
						singerList.add(song);
					}
	                map.put("singerList", singerList);
	                map.put("ads", ads);
	                map.put("result", "01");
			}else{
				map.put("result", "05");
			}
		}catch (Exception e){
			logger.error(e.toString(), e);
		}finally{
			logAfter(logger);
		}
		
		return AppUtil.returnObject(new PageData(), map);
	}
	
	
	/**
	 * 音乐中心-歌手推荐-获取歌手歌曲列表
	 * @Author zhaozhenhua
	 * @date   2018年1月19日
	 * @return
	 */
	@RequestMapping(value="/getsingersonglist")
	@ResponseBody
	public Object getSingerSongList(){
		logBefore(logger, "获得所有排行榜列表接口(每个排行榜显示3首)接口");
		PageData pd = new PageData();
		pd = this.getPageData();
		Map<String,Object> map = new HashMap<String,Object>();
		AppUtil.returnObject(new PageData(), map);
		String result="";
		try{
			if(Tools.checkKey("SINGERSONGLIST", pd.getString("FKEY"))){	//检验请求key值是否合法
				if(AppUtil.checkParam("getsingersonglist", pd)){	//检查参数
					//String singer=	"7996,7994,7997,7998";
					//调用百度音乐api接口
	                String singerURL="";
                	singerURL="http://tingapi.ting.baidu.com/v1/restserver/ting?from=qianqian&version=2.1.0&method=baidu.ting.artist.getSongList&format=json&order=2&tinguid="+pd.getString("singer_id")+"&offset="+pd.getString("offset")+"&limits=50";
                	result = HttpClientUtil.httpGetRequest(singerURL);
    				//将返回的Http请求数据转变成PageData实体对象
    				PageData p = gson.fromJson(result, PageData.class);
    				//将排行榜图片改成自定义图片
    				String json = gson.toJson(p.get("songlist"));
    				List<PageData> songlist = ToolsUtil.fromJson(json, PageData.class);
		            map.put("result", "01");
		            map.put("pd", songlist);
				}
			}else{
				result = "05";
				map.put("result", result);
			}
		}catch (Exception e){
			logger.error(e.toString(), e);
		}finally{
			logAfter(logger);
		}
		return AppUtil.returnObject(new PageData(), map);
	}
	
	/**
	 * 音乐中心-电台
	 * @Author zhaozhenhua
	 * @date   2018年1月19日
	 * @return
	 */
	@RequestMapping(value="/getradiostationlist")
	@ResponseBody
	public Object getRedioStationList(){
		logBefore(logger, "音乐中心-电台");
		PageData pd = new PageData();
		pd = this.getPageData();
		Map<String,Object> map = new HashMap<String,Object>();
		AppUtil.returnObject(new PageData(), map);
		String result="";
		try{
			if(Tools.checkKey("RADIOSTATIONLIST", pd.getString("FKEY"))){	//检验请求key值是否合法
					//调用百度音乐api接口
	                String singerURL="";
                	singerURL="http://tingapi.ting.baidu.com/v1/restserver/ting?from=qianqian&version=2.1.0&method=baidu.ting.radio.getCategoryList&format=json";
                	result = HttpClientUtil.httpGetRequest(singerURL);
    				//将返回的Http请求数据转变成PageData实体对象
    				PageData p = gson.fromJson(result, PageData.class);
    				//将排行榜图片改成自定义图片
    				String json = gson.toJson(p.get("result"));
    				List<PageData> res = ToolsUtil.fromJson(json, PageData.class);
    				String json1 = gson.toJson(res.get(0), PageData.class);
    				PageData p1=gson.fromJson(json1,PageData.class);
    				String json2 = gson.toJson(p1.get("channellist"));
    				List<PageData> channellist = ToolsUtil.fromJson(json2, PageData.class);
		            map.put("result", "01");
		            map.put("pd", channellist);
				}
		}catch (Exception e){
			logger.error(e.toString(), e);
		}finally{
			logAfter(logger);
		}
		return AppUtil.returnObject(new PageData(), map);
	}
	
	/**
	 * 音乐中心-曲库推荐
	 * @Author zhaozhenhua
	 * @date   2018年1月19日
	 * @return
	 */
	@RequestMapping(value="/getmusiclibrary")
	@ResponseBody
	public Object getMusicLibrary(){
		logBefore(logger, "音乐中心-曲库推荐");
		PageData pd = new PageData();
		pd = this.getPageData();
		Map<String,Object> map = new HashMap<String,Object>();
		AppUtil.returnObject(new PageData(), map);
		String result="";
		try{
			if(Tools.checkKey("MUSICLIBRARY", pd.getString("FKEY"))){	//检验请求key值是否合法
					//调用百度音乐api接口
	                String singerURL="";
                	singerURL="http://tingapi.ting.baidu.com/v1/restserver/ting?from=qianqian&version=2.1.0&method=baidu.ting.plaza.getRecommendAlbum&format=json&offset=0&limit=70";
                	result = HttpClientUtil.httpGetRequest(singerURL);
    				//将返回的Http请求数据转变成PageData实体对象
    				PageData p = gson.fromJson(result, PageData.class);
    				//将排行榜图片改成自定义图片
    				String json1 = gson.toJson(p.get("plaze_album_list"));
    				PageData p2 = gson.fromJson(json1, PageData.class);
    				String json2 = gson.toJson(p2.get("RM"));
    				PageData p3 = gson.fromJson(json2, PageData.class);
    				String json3 = gson.toJson(p3.get("album_list"));
    				PageData p4 = gson.fromJson(json3, PageData.class);
    				String json4 = gson.toJson(p4.get("list"));
    				List<PageData> temp = ToolsUtil.fromJson(json4, PageData.class);
    				List<PageData> albumlist=new ArrayList<>();
    				for (PageData pdData : temp) {
						switch (Integer.parseInt(pdData.getString("album_id"))) {
						case 568635221:
							albumlist.add(pdData);
							break;
						case 568761665:
							albumlist.add(pdData);
							break;
						case 568822524:
							albumlist.add(pdData);
							break;
						case 569131439:
							albumlist.add(pdData);
							break;
						case 568994015:
							albumlist.add(pdData);
							break;
						case 568855270:
							albumlist.add(pdData);
							break;
						case 569499527:
							albumlist.add(pdData);
							break;
						case 569464266:
							albumlist.add(pdData);
							break;

						default:
							break;
						}
					}
		            map.put("result", "01");
		            map.put("pd", albumlist);
				}
		}catch (Exception e){
			logger.error(e.toString(), e);
		}finally{
			logAfter(logger);
		}
		return AppUtil.returnObject(new PageData(), map);
	}
	
	/**
	 * 音乐中心-歌单推荐
	 * @Author zhaozhenhua
	 * @date   2018年1月20日
	 * @return
	 */
	@RequestMapping(value="/getsongsrecommend")
	@ResponseBody
	public Object getSongsRecommend(){
		logBefore(logger, "音乐中心-歌单推荐");
		PageData pd = new PageData();
		pd = this.getPageData();
		Map<String,Object> map = new HashMap<String,Object>();
		AppUtil.returnObject(new PageData(), map);
		String result="";
		List<PageData> song_list=new ArrayList<>();
		List<PageData> list=new ArrayList<>();
		try{
			if(Tools.checkKey("SONGRECOMMEND", pd.getString("FKEY"))){	//检验请求key值是否合法
				/*if(AppUtil.checkParam("billlist", pd)){	//检查参数
*/				String str=	"6,7,8,9,18,20,23";
				//调用百度音乐api接口
                String[] split = str.split(",");
                String strURL="";
                for (String s : split) {
                	PageData songrec =new PageData();
                	strURL="http://tingapi.ting.baidu.com/v1/restserver/ting?method=baidu.ting.billboard.billList&type="+s+"&size=50&offset="+pd.getString("offset");
                	result = HttpClientUtil.httpGetRequest(strURL);
    				//将返回的Http请求数据转变成PageData实体对象
    				PageData p = gson.fromJson(result, PageData.class);
    				String json2 = gson.toJson(p.get("song_list"));
    			    song_list = ToolsUtil.fromJson(json2, PageData.class);
    				//将排行榜图片改成自定义图片
    				String json = gson.toJson(p.get("billboard"));
    				PageData pda = gson.fromJson(json, PageData.class);
    				//String path = Tools.readTxtFileAll(Const.IMAGEPATH, "UTF-8");
    				/*switch (Integer.parseInt(s)) {
    				case 21:
    					pda.put("pic_s640", path+"musicimgs/billlistimgs/music_image_34@2x.png");
    					break;
    				case 1:
    					pda.put("pic_s640", path+"musicimgs/billlistimgs/music_image_35@2x.png");
    					break;
    				case 22:
    					pda.put("pic_s640", path+"musicimgs/billlistimgs/music_image_40@2x.png");
    					break;
    				case 2:
    					pda.put("pic_s640", path+"musicimgs/billlistimgs/music_image_37@2x.png");
    					break;
    				case 11:
    					pda.put("pic_s640", path+"musicimgs/billlistimgs/music_image_36@2x.png");
    					break;
    				case 24:
    					pda.put("pic_s640", path+"musicimgs/billlistimgs/music_image_38@2x.png");
    					break;
    				case 12:
    					pda.put("pic_s640", path+"musicimgs/billlistimgs/music_image_39@2x.png");
    					break;
    				default:
    					break;
    				}*/
    				//将修改完的字段传入p对象中
    				songrec.put("billboard", pda);
    				songrec.put("song_list", song_list);
    				list.add(songrec);
                }
                map.put("result", "01");
                map.put("song_recommend", list);
			}else{
				result = "05";
				map.put("result", result);
			}
		}catch (Exception e){
			logger.error(e.toString(), e);
		}finally{
			logAfter(logger);
		}
		return AppUtil.returnObject(new PageData(), map);
	}
}
